﻿#ifndef NEWUSER_H
#define NEWUSER_H

#include <QWidget>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QDebug>

#include <QStringListModel>
#include "deleteuser.h"
#include "confirmuser.h"
#include <QCompleter>

#include <QValidator>
namespace Ui {
class newUser;
}

class newUser : public QWidget
{
    Q_OBJECT

public:
    explicit newUser(QWidget *parent = nullptr);
    ~newUser();
protected:
    virtual void changeEvent(QEvent* event);

    void  showEvent(QShowEvent *event);
private:
    //设置输入限制
    void setInputLimit();
    //初始化用户列表
    void initUserTableWidget();
    //更新用户列表
    void updateUserTableWidget();
    //填充Usertable
    void fillUserTable(const QList<QVariantMap> &);
    //填充用户数据
    void fillUserData(int);
signals:
    void signalUpdateUserTable();

private slots:
    void on_newUser_pushButton_clicked();

    void on_delete_pushButton_clicked();

    void on_save_pushButton_clicked();

    void on_search_pushButton_clicked();

    void on_modify_pushButton_clicked();

    void on_selectUser_pushButton_clicked();

private:

    //清空用户页面
    void clearUserData();
public slots:
    void slotUpdateUserTable();

signals:
    void signalCheckUserChanged(int);
private:
    Ui::newUser *ui;
    QSqlDatabase  m_userDataBase; //建立QT和数据库的连接
    ST_PatientMsg st_CurrentUserData;
    uint32_t m_currentID; //系统给用户分配的ID
    int m_currentRows;          //当前有效行数
    int m_currentUserId;        //当前用户ID
    QStringListModel stringListModel;
    QStringList wordList;       //自动补全文字集
    DeleteUser  *m_deleteUser;   //删除用户
    ConfirmUser *m_confirUser;  //选择用户
    QCompleter *m_completer;    //自动补全
    QValidator* m_validator;

    
};

#endif // NEWUSER_H
